package com.roc.web.action.orgmain;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

@SuppressWarnings("serial")
public class OrgMainSearchCondition  extends BaseSearchCondition {

	private String name;  //机构名称
	private String code;  //区域编码
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		if(Constance.isNotEmpty(name)){ 
			filedBeanList.add(new WhereHQLFieldBean("T.org_name", name.trim(), "=", false));
		}
		if(Constance.isNotEmpty(code)&&!"999".equals(code)){ 
			filedBeanList.add(new WhereHQLFieldBean("T.area_id", code.trim(), "=", false));
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		return "  select count(1)  FROM  TBL_ORG_MAIN  t  where 1=1  ";
	}

	@Override
	protected String getSearchHQL() {
		return " select t.org_code,t.org_name,"+
       "(select a.name from tbl_area a where a.id = t.area_id) area_name,"+
       "(select i.ins_name from tbl_ins_inf i where i.ins_id_cd = t.super_id) sd_org_name,"+
       "(select o.real_name from t_operators o where to_char(o.id) = t.opr_id) opr_name,"+
       "t.crt_ts,t.status   from TBL_ORG_MAIN t where 1 = 1";
	}

	@Override
	protected String getOrderPartOfHQL() {
		return "  ";
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	

}
